package CountNumberTime;

import java.util.*;

public class CountNumberTime {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		System.out.println("请输入一串字符串");
		String s = input.nextLine();

		TreeMap<Character, Integer> treemap = new TreeMap<Character, Integer>();

		for (int i = 0; i < s.length(); i++) {
			char a = s.charAt(i);

			Integer value = treemap.get(a);
			if (value == null) {
				treemap.put(a, 1);
			} else {
				value++;
				treemap.put(a, value);
			}

		}

		StringBuilder SB = new StringBuilder();

		Set<Character> keyset = treemap.keySet();
		for (Character a : keyset) {
			Integer b = treemap.get(a);

			SB.append(a).append('(').append(b).append(')');
		}
		String sb = SB.toString();
		System.out.println(sb+'\n');

	}

}
